# requests基于urllib3, 拥有urllib2的所有特性, 所以用requests可以打天下

import requests

kw = {'wd':'女神异闻录'}

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) \
    Chrome/54.0.2840.99 Safari/537.36"}

# get方法可以解决GET的所有情况, 包括url编码, 会自动转
response = requests.get("http://www.baidu.com/s?", params = kw, headers = headers)

res_body_bytes = response.content   # 这个进行decode就是res_body_str了
res_body_str = response.text
res_url = response.url
res_encoding = response.encoding
res_statuscode = response.status_code

print(res_body_str)
print(res_url)
print(res_encoding)
print(res_statuscode)

